﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.models.fountain {
    import net.wooga.pets.events.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.utils.*;

    public class SymbolModel extends Actor {

        private var _symbols:DictStorage;

        public function get symbols():Object{
            return (this._symbols.storage);
        }
        public function set symbols(_arg1:Object):void{
            var _local3:String;
            var _local2:Boolean;
            for (_local3 in _arg1) {
                if (((this._symbols) && ((int(_arg1[_local3]) > int(this._symbols.get(_local3)))))){
                    l((("c key " + _local3) + "was added"));
                    _local2 = true;
                    break;
                };
            };
            this._symbols = new DictStorage(_arg1);
            dispatch(new InfoEvent(EventConstants.UPDATE_SYMBOLS, null, _local2));
        }
        public function hasSymbols(_arg1:Object):Boolean{
            var _local2:String;
            for (_local2 in _arg1) {
                if (int(this._symbols.get(_local2)) < int(_arg1[_local2])){
                    return (false);
                };
            };
            return (true);
        }
        public function calcCollectedPercentage(_arg1:Object):int{
            var _local4:int;
            var _local5:String;
            var _local2:int;
            var _local3:int;
            for (_local5 in _arg1) {
                _local4 = int(_arg1[_local5]);
                _local2 = (_local2 + _local4);
                _local3 = (_local3 + Numbers.constrain(int(this._symbols.get(_local5)), 0, _local4));
            };
            return (Math.round(((_local3 / _local2) * 100)));
        }
        public function fillUp(_arg1:Object):void{
            var _local2:String;
            var _local3:int;
            for (_local2 in _arg1) {
                _local3 = int(_arg1[_local2]);
                if (int(this._symbols.get(_local2)) < _local3){
                    this._symbols.set(_local2, _local3);
                };
            };
        }
        public function getAmountOfMissingGems(_arg1:Object):int{
            var _local3:String;
            var _local4:int;
            var _local5:int;
            var _local2:int;
            for (_local3 in _arg1) {
                _local4 = int(_arg1[_local3]);
                _local5 = int(this._symbols.get(_local3));
                if (_local5 < _local4){
                    _local2 = (_local2 + (_local4 - _local5));
                };
            };
            return (_local2);
        }

    }
}//package net.wooga.pets.models.fountain 
